package org.jzyan.framework.feign.config;

import feign.Logger;
import feign.Retryer;
import org.jzyan.framework.feign.interceptor.FeignHeaderInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * <p>
 * OpenFeignConfig
 * </p>
 *
 * @author jzyan
 * @since 2023-02-16
 */
@Configuration
public class OpenFeignConfig {

    @Bean
    public FeignHeaderInterceptor feignHeaderInterceptor() {
        return new FeignHeaderInterceptor();
    }

    @Bean
    public Logger.Level loggerLevel() {
        return Logger.Level.FULL;
    }

    @Bean
    public Retryer retryer() {
        /** 重试间隔100ms，最大重试间隔时间为1秒，重试次数为2次 */
        return new Retryer.Default(100, TimeUnit.SECONDS.toMillis(1L), 2);
    }

}
